
const jwt = require("jsonwebtoken")
const sercet = "dasdasrrqe" // 密钥
module.exports = {
    // 加密
    sign: (data, timeout = "1h") => {
        return jwt.sign(data, sercet, {
            expiresIn: timeout
        })
    },
    // 解密
    verify: (token) => {
        try {
            return jwt.verify(token, sercet)
        } catch (error) {
            return false
        }
    }
}
